package com.situ.stl.controller;

import com.situ.stl.entity.Result;
import com.situ.stl.util.UploadUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 */
@RestController
@CrossOrigin
@RequestMapping( value = "/upload")
public class UploadController{

    /**
     */
    @Value( value = "${file.path}")
    private String path;

    /**
     * 文件上传
     */
    @PostMapping
    public Result upload(MultipartFile file) {
        String fileName = UploadUtil.save(file, path);
        return Result.success("/upload/"+fileName);
    }

}
